package com.example.adminsystem.common;

import lombok.Data;

@Data
public class ResponseResult<T> {
    private boolean success; // 表示请求是否成功
    private String message;
    private T data;

    public ResponseResult(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(true, "请求成功", data);
    }

    public static <T> ResponseResult<T> success(String message, T data) {
        return new ResponseResult<>(true, message, data);
    }

    public static <T> ResponseResult<T> success(String message) {
        return new ResponseResult<>(true, message, null);
    }

    public static <T> ResponseResult<T> error(String message) {
        return new ResponseResult<>(false, message, null);
    }

    public static <T> ResponseResult<T> notFound() {
        return new ResponseResult<>(false, "资源未找到", null);
    }

    public static <T> ResponseResult<T> success() {
        return new ResponseResult<>(true, "操作成功", null);
    }
}
